<?php defined('SYSPATH') or die('No direct access allowed.');


class Model_Project_Container extends ORM {

		// Relationships
	protected $_belongs_to = array('project' => array('model' => 'desktop_project','foreign_key' => 'project_id'));

        
        public function get_containers($project_id)
        {
            $containers = DB::select('id','data', 'published')
                            ->from('project_containers')
                            ->where('project_id', '=', $project_id)
                            ->order_by('order')
                            ->as_object()
                            ->execute();
            
            return $containers;
        }
        
        public function publish_all($project_id)
        {
            $query = DB::update('project_containers')
                       ->set(array('published' => 1))
                       ->where('project_id', '=', (int) $project_id)
                       ->execute();
        
            return $query;
        }
}